<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name=viewport content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
	<title>js跳表</title>
</head>
<body>
<script>
function Node(id,next,down){
	this.id=id
	this.next=next
	this.down=down
}
var begin=new Node(1)
var tmp=new Node(1),tmp1=new Node(1),tmp2=begin
tmp2.down=tmp1,tmp1.down=tmp
for(var i=2;i<10;i++){
	var node=new Node(i)
	tmp.next=node
	tmp=node
	var j=0
	while(Math.random()>0.5&&j<2){
		j++
		this['tmp'+j].next=new Node(i)
		this['tmp'+j]=this['tmp'+j].next
		this['tmp'+j].down=node
		node=this['tmp'+j]
	}
	console.log(j)
}
function find(id){
	var tmp=begin
	var pre=begin
	while(tmp){
		console.log(tmp.id)
		if(tmp.id<id){
			pre=tmp
			tmp=tmp.next || tmp.down
		}else if(tmp.id>id){
			tmp=pre.down
		}else{
			return tmp
		}
	}
}
</script>
</body>
</html>